mod tray;
mod win_op;

#[path ="./api/mod.rs"]
mod apis;

// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}! You've been greeted from Rust!", name)
}

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_store::Builder::new().build())
        .plugin(tauri_plugin_dialog::init())
        .setup(|app| {
            #[cfg(all(desktop))]
            {
                let handle = app.handle();
                tray::create_tray(handle)?;
                win_op::close_dialog(handle);
            }

            Ok(())
        })
        .plugin(tauri_plugin_shell::init())
        .invoke_handler(tauri::generate_handler![greet,apis::local::yzg_login,apis::local::logout,apis::local::http_headers,apis::local::md5_str,
            apis::local::get_mac,apis::local::fetch,apis::local::snow_flake_id])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
